<?php
$current_route = sfContext::getInstance()->getRouting()->getCurrentInternalUri(true);
$anchor_list = !isset($pagerType)?'#l':'';
$paginator_parameter_name_prefix = isset($paginator_parameter_name_prefix)?$paginator_parameter_name_prefix:'';
?>



<div id="numerArea<?php echo (isset($pagerType))?$pagerType:''?>">

  <?php if (isset($sort) && count($sort)) : ?>
  <form name="frmSort" method="GET" action="?#l">
    <div class="showPg">
      <label class="lblBox1">Sort By:</label>
      <div class="drpdwnBox">
        <select name="sort" class="drpdwnBoxC1" onChange="document.frmSort.submit();">
          <?php foreach ($sort as $k => $v) : ?>
          <option value="<?php echo $k; ?>"<?php if ($sf_request->hasParameter(sfConfig::get('app_sort_parameter_name')) && $sf_request->getParameter(sfConfig::get('app_sort_parameter_name')) == $k) : ?> selected<?php endif; ?>><?php echo $v; ?></option>
          <?php endforeach; ?>
        </select>
        <?php if (isset($sort2) && count($sort2)) : ?>
        <?php echo $sort2Label; ?>: <select name="sort2" class="drpdwnBoxC1" onChange="document.frmSort.submit();">
          <?php foreach ($sort2 as $k => $v) : ?>
          <option value="<?php echo $k; ?>"<?php if ($sf_request->hasParameter(sfConfig::get('app_sort_parameter_name').'2') && $sf_request->getParameter(sfConfig::get('app_sort_parameter_name').'2') == $k) : ?> selected<?php endif; ?>><?php echo $v; ?></option>
          <?php endforeach; ?>
        </select>
        <?php endif; ?>
      </div>
    </div>
  </form>
  <?php endif; ?>

  <?php
  $sortParam = "";
  if ($sf_request->hasParameter(sfConfig::get('app_sort_parameter_name'))) {
    $sortParam .= "&" . sfConfig::get('app_sort_parameter_name') . "=" . $sf_request->getParameter(sfConfig::get('app_sort_parameter_name'));
  }
  if ($sf_request->hasParameter(sfConfig::get('app_sort_parameter_name').'2')) {
    $sortParam .= "&" . sfConfig::get('app_sort_parameter_name').'2' . "=" . $sf_request->getParameter(sfConfig::get('app_sort_parameter_name').'2');
  }
  ?>

  <?php if(is_object($pager) && $pager->getNbResults()>0):?>
  <div class="showNo">
    <ul class="pagination right">
        <?php if($pager->getFirstPage() != $pager->getPage() && $pager->getFirstPage() != $pager->getPreviousPage()):?><li><?php echo link_to('First', $current_route.StringUtil::getDelimeter($current_route).sfConfig::get("app_paginator_parameter_name").$paginator_parameter_name_prefix.'='.$pager->getFirstPage().$sortParam.$anchor_list, array('class'=>'first')) ?> </li><?php endif;?>
        <?php if($pager->getFirstPage() != $pager->getPage()):?><li><?php echo link_to('Previous', $current_route.StringUtil::getDelimeter($current_route).sfConfig::get("app_paginator_parameter_name").$paginator_parameter_name_prefix.'='.$pager->getPreviousPage().$sortParam.$anchor_list, array('class'=>'prev')) ?> </li><?php endif;?>
      <li class="count"><span class="countspan"><?php echo $pager->getFirstIndice()?> - <?php echo $pager->getLastIndice()?> of <?php echo $pager->getNbResults()?></span></li>
        <?php if($pager->getLastPage() != $pager->getPage()):?><li><?php echo link_to('Next', $current_route.StringUtil::getDelimeter($current_route).sfConfig::get("app_paginator_parameter_name").$paginator_parameter_name_prefix.'='.$pager->getNextPage().$sortParam.$anchor_list, array('class'=>'next')) ?> </li><?php endif;?>
        <?php if($pager->getLastPage() != $pager->getPage() && $pager->getLastPage() != $pager->getNextPage()):?><li><?php echo link_to('Last', $current_route.StringUtil::getDelimeter($current_route).sfConfig::get("app_paginator_parameter_name").$paginator_parameter_name_prefix.'='.$pager->getLastPage().$sortParam.$anchor_list, array('class'=>'last')) ?> </li><?php endif;?>
    </ul>
  </div>
  <?php endif; ?>
</div>